using System;
using DotNetNuke.Modules.Announcements;
using DotNetNuke.Entities.Users;

namespace MetaPostProvider.Announcements
{
    public partial class ControllerFactory
    {
        public class AnnouncementsController_4_0_0 : AnnouncementsController_Proxy
        {
            private int _ModuleId;
            protected int ModuleId
            {
                get { return _ModuleId; }
            }

            /// <summary>
            /// Initializes a new instance of the AnnouncementsController_3_3_5 class.
            /// </summary>
            /// <param name="moduleId"></param>
            protected internal AnnouncementsController_4_0_0(int ModuleId)
            {
                // NOTE: One of the changes from 03.04.00 is that the
                //       internal dataprovider method names (which we're tapping
                //       into for adding) have changed. Ergo, AddAnnouncements from
                //       the old version is now simply called Add.
                _Add = DataProvider.Instance().GetType().GetMethod("Add");
                this._ModuleId = ModuleId;
            }

            public override void Delete(int ItemID)
            {
                DeleteProxy.Invoke(this, new object[] { ModuleId, ItemID });
            }

            public override int Add(AnnouncementInfo objAnnouncement)
            {
                return Convert.ToInt32(AddProxy.Invoke(DataProvider.Instance(), new object[] { objAnnouncement.ModuleId, objAnnouncement.CreatedByUser, objAnnouncement.CreatedDate, objAnnouncement.Title, objAnnouncement.ImageSource, objAnnouncement.Url, objAnnouncement.Description, objAnnouncement.ViewOrder, objAnnouncement.PublishDate, objAnnouncement.ExpireDate }));
            }
        }
    }
}
